package group2assignone.view.manager;

import group2assignone.func.UCCtoALAdapter;
import group2assignone.model.Customer;
import group2assignone.model.Person;
import group2assignone.ucm.customer.UCCancelGuest;
import group2assignone.ucm.customer.UCCreateCustomerAccount;
import group2assignone.view.OurView;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

/**
 * This GUI shows the details of the selected user.
 * @author group2
 */
public class UserDetailsView extends OurView {

    private JButton createAccount = new JButton("Create Account");
    private JButton cancel = new JButton("Cancel");
    private JLabel userName;
    private JLabel password;
    private JLabel fName;
    private JLabel lName;
    private JLabel dob;
    private JLabel userNameLab = new JLabel("User Name: ");
    private JLabel passwordLab = new JLabel("Password: ");
    private JLabel fNameLab = new JLabel("First Name: ");
    private JLabel lNameLab = new JLabel("Last Name: ");
    private JLabel dobLab = new JLabel("Date Of Birth: ");
    private GridLayout grid;
    private Person p;

    public UserDetailsView(Person p) {
        this.p = p;
    }

    /**
     * Function to add the GUI components to the frame.
     */
    @Override
    public void addComponents() {

        setTitle("Create Account");

        northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.LINE_AXIS));
        //custLab.setAlignmentX(JLabel.LEFT);
        //northPanel.add(custLab);

        grid = new GridLayout(3, 2, 2, 1);
        westPanel.setLayout(grid);
        eastPanel.setLayout(grid);
        grid.setVgap(20);

        setValues(p);

        westPanel.add(userNameLab);
        westPanel.add(userName);
        westPanel.add(passwordLab);
        westPanel.add(password);
        westPanel.add(fNameLab);
        westPanel.add(fName);
        eastPanel.add(lNameLab);
        eastPanel.add(lName);
        eastPanel.add(dobLab);
        eastPanel.add(dob);

        southPanel.add(createAccount);
        southPanel.add(cancel);

        eastPanel.setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 20));
        westPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 10));
        northPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
        southPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

        cancel.addActionListener(new UCCtoALAdapter(new UCCancelGuest(this)));
    }

    private void setValues(Person p) {
        userName = new JLabel(p.getUsername());
        password = new JLabel(p.getPassword());
        fName = new JLabel(p.getFName());
        lName = new JLabel(p.getLName());
        dob = new JLabel(p.getDob());
    }
}


